<script>
import request from "@/utils/request.js";
import http from "@/utils/http.js";
import {ElMessage} from "element-plus";
import {treeDataTranslate} from "@/utils/index.js";

export default {
  name: "index",
  data() {
    return {
      dataList: []
    }
  },
  methods:{
    getDataList(){
      http.get('/tzSysMenu/table').then(res => {
        console.log(res)
        this.dataList = treeDataTranslate(res.data, 'menuId')
      })
    },
    doLogin(){



     http.post('/user/doLogin',{username:'admin',password:'admin'}).then(res=>{
       ElMessage.success(res.msg)
     })
    }
  },
  mounted() {
    this.getDataList()
  }
}
</script>

<template>
  <el-form
      :inline="true"
  >
    <el-form-item>
      <el-button
          type="primary"
          @click="doLogin()"
      >
        一键登录
      </el-button>
    </el-form-item>
  </el-form>
  <el-table
      :data="dataList"
      border
      style="width: 100%;"
      row-key="menuId"
  >
    <el-table-column
        prop="name"
        header-align="center"
        tree-key="menuId"
        width="150"
        label="名称"

    />
    <el-table-column
        header-align="center"
        align="center"
        label="图标"
    >
<!--      <template #default="scope">-->
<!--        <svg-icon-->
<!--            :icon-class="`icon-${scope.row.icon}`"-->
<!--        />-->
<!--      </template>-->
    </el-table-column>
    <el-table-column
        prop="type"
        header-align="center"
        align="center"
        label="类型"
    >
      <template #default="scope">
        <el-tag
            v-if="scope.row.type === 0"
        >
          目录
        </el-tag>
        <el-tag
            v-else-if="scope.row.type === 1"

            type="success"
        >
          菜单
        </el-tag>
        <el-tag
            v-else-if="scope.row.type === 2"

            type="info"
        >
          按钮
        </el-tag>
      </template>
    </el-table-column>
    <el-table-column
        prop="orderNum"
        header-align="center"
        align="center"
        label="排序号"
    />
    <el-table-column
        prop="url"
        header-align="center"
        align="center"
        width="150"
        :show-overflow-tooltip="true"
        label="菜单URL"
    >
      <template #default="scope">
        {{ scope.row.url || '-' }}
      </template>
    </el-table-column>
    <el-table-column
        prop="perms"
        header-align="center"
        align="center"
        width="150"
        :show-overflow-tooltip="true"
        label="授权标识"
    >
      <template #default="scope">
        {{ scope.row.perms || '-' }}
      </template>
    </el-table-column>
    <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="150"
        label="操作"
    >
      <template #default="scope">
        <el-button

            type="text"

            @click="onAddOrUpdate(scope.row.menuId)"
        >
          修改
        </el-button>
        <el-button

            type="text"

            @click="onDelete(scope.row.menuId)"
        >
          删除
        </el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<style scoped>

</style>